﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using TV_2013.Handle;
using TV_2013.Model;

namespace TV_2013.View.Lesson
{
    public partial class LessonTemplate : PhoneApplicationPage
    {
        ReadData readData = new ReadData("Data/DataLesson.xml");
        LessonModel2 lessonModel = new LessonModel2();
        
        public LessonTemplate()
        {
            InitializeComponent();
        }

        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            string id = NavigationContext.QueryString["id"];
            lessonModel = readData.GetDataByAttribute2(id,6); // id cua lesson va so luong sound de load
            img_Left.Source = new BitmapImage(new Uri(lessonModel.ImgLeft, UriKind.Relative));
            img_Right.Source = new BitmapImage(new Uri(lessonModel.ImgRight,UriKind.Relative));

            txt_Left.Text = lessonModel.TextLeft;
            txt_Right.Text = lessonModel.TextRight;

            txt_ContentLeft.Text = lessonModel.ContentLeft;
            txt_ContentRight.Text = lessonModel.ContentRight;
        }

        private void txt_Left_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            sound.Source = new Uri(lessonModel.ArraySound[0], UriKind.Relative);
        }

        private void img_Left_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            sound.Source = new Uri(lessonModel.ArraySound[2], UriKind.Relative);
        }

        private void txt_ContentLeft_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            sound.Source = new Uri(lessonModel.ArraySound[4], UriKind.Relative);
        }

        private void txt_Right_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            sound.Source = new Uri(lessonModel.ArraySound[1], UriKind.Relative);
        }

        private void img_Right_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            sound.Source = new Uri(lessonModel.ArraySound[3], UriKind.Relative);
        }

        private void txt_ContentRight_Tap(object sender, System.Windows.Input.GestureEventArgs e)
        {
            sound.Source = new Uri(lessonModel.ArraySound[5], UriKind.Relative);
        }
    }
}